import java.util.*;
import java.lang.*;

public class EprimeSum {
    public static void main(String[] args) {
        int s,sum;
        sum=0;
        Scanner input=new Scanner(System.in);
        s=input.nextInt();
        for (int i = s/2; i > 0 ; i--) {
            if(isPrime((double)i)==false || isPrime((double) (s-i))==false)
                continue;
            if((s-i)*i>sum)
                sum=(s-i)*i;
        }
        System.out.println(sum);
    }
    public static boolean isPrime(double x){
        int i,k;
        k=(int)Math.sqrt(x);
        for (i = 2; i <= k; i++) {
            if(x%i==0)
                return false;
        }
        if(i>k)
            return true;
        return false;
    }
}
